<%=pageHead%>
<link href="genlayout.css" rel="stylesheet" type="text/css" />
<title><%=title%></title>
<script src="script.js" type="text/javascript"></script><%
( 
  .name=getp('name');
  .password=getp('password');
  ( getRes(name) ?
    ( pwCheck==() ?
      ( [res].pwr = getRes(getp('name')+'Password');
				[{hash,salt}].pw=checkedEval(loadDef(pwr))!;
        pw!=() && hex_hmac_sha1{password,pw.salt} == pw.hash ?
        ( @getp('newpwd1')!=0 && getp('newpwd2')==getp('newpwd1') 
          ? ( addOrChangeUser{name,getp('newpwd1')}; );
          1
        )
      ) :
      pwCheck{name,password}
    )
  ) ?
  (
    getUser!; 
    putv{"user",name};
    putline{'"',name, '" is logging in.'};%>
          <script type="text/javascript">location.replace(getHTTPPath(<%=port%>)+'resourcerer.tsp'+'<%=getp('resource').!(@$!=0?'?resource='+tyleToUrl!)%>');</script><%
  ) :
  (%>
            <meta http-equiv="refresh" content="0;URL=login.tsp?action=incorrect&name=<%=name%>" /><%
  );
);%>
</head>
</html>
